package com.dhecp.project.api.controller;

import com.dhecp.common.core.controller.BaseController;
import com.dhecp.common.core.page.TableDataInfo;
import com.dhecp.project.api.domain.ApiLog;
import com.dhecp.project.api.service.ApiLogService;
import com.dhecp.project.quartz.domain.SysJob;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/common/apilog")
public class ApiLogController extends BaseController {

    private String prefix = "common/apilog";

    @Autowired
    private ApiLogService apiLogService;

    @RequiresPermissions("common:apilog:view")
    @GetMapping()
    public String apilog()
    {
        return prefix + "/apilog";
    }

    @RequiresPermissions("common:apilog:list")
    @RequestMapping("/list")
    @ResponseBody
    public TableDataInfo list(@RequestParam Map<String, Object> params)
    {
        startPage();
        List<ApiLog> list = apiLogService.queryApiLogList(params);
        return getDataTable(list);
    }

    /**
     * API调度日志详情
     */
    @RequiresPermissions("common:apilog:view")
    @GetMapping("/detail/{logId}")
    public String detail(@PathVariable("logId") int logId, ModelMap mmap)
    {
        mmap.put("apilog", apiLogService.queryApiLogById(logId));
        return prefix + "/apilog_detail";
    }

}
